home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Halma 1.1.source Folder / Halma ƒ / Shell ƒ / generic open.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-17  |  2.2 KB  |  83 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        generic open.c
  4.  
  5. Purpose:    This module handles opening saved games via apple events.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program in a file named "GNU General Public License".
  19. If not, write to the Free Software Foundation, 675 Mass Ave,
  20. Cambridge, MA 02139, USA.
  21.  
  22. \**********************************************************************/
  23.  
  24. #include "program globals.h"
  25. #include "graphics.h"
  26. #include "generic open.h"
  27. #include "halma load-save.h"
  28. #include "debinhex dispatch.h"
  29. #include "file management.h"
  30. #include "environment.h"
  31. #include "dialogs.h"
  32. #include "error.h"
  33.  
  34. void GenericOpen(FSSpec *myFSS)
  35. {
  36.     enum ErrorTypes        resultCode;
  37.     
  38.     if (!gInProgress)
  39.     {
  40.         switch (GetFileType(myFSS))
  41.         {
  42.             case SAVE_TYPE:
  43.                 if (!gTheWindow[kMainWindow])
  44.                 {
  45.                     gameFile=*myFSS;
  46.                     GetSavedGame(&gameFile);
  47.                 }
  48.                 else
  49.                 {
  50.                     PositionDialog('ALRT', smallAlert);
  51.                     ParamText("\pPlease close the current game before starting another.","\p","\p","\p");
  52.                     StopAlert(smallAlert, 0L);
  53.                 }
  54.                 break;
  55.             case 'TEXT':
  56.             case '????':
  57.                 inputFS=*myFSS;
  58.                 HandleError(DeBinHexDispatch(), FALSE);
  59.                 break;
  60.         }
  61.     }
  62.     else
  63.     {
  64.         PositionDialog('ALRT', smallAlert);
  65.         ParamText("\pPlease wait until the current file is done before starting another.","\p","\p","\p");
  66.         StopAlert(smallAlert, 0L);
  67.     }
  68. }
  69.  
  70. OSType GetFileType(FSSpec *myFSS)
  71. {
  72.     HParamBlockRec    paramBlock;
  73.     
  74.     paramBlock.fileParam.ioCompletion=0L;
  75.     paramBlock.fileParam.ioNamePtr=myFSS->name;
  76.     paramBlock.fileParam.ioVRefNum=myFSS->vRefNum;
  77.     paramBlock.fileParam.ioFDirIndex=0;
  78.     paramBlock.fileParam.ioDirID=myFSS->parID;
  79.     PBHGetFInfo(¶mBlock, FALSE);
  80.  
  81.     return paramBlock.fileParam.ioFlFndrInfo.fdType;
  82. }
  83.